<?php

namespace app\api\server\user;

use app\api\model\user\MusicCollectionApiModel;
use app\api\ServerBase;
use app\logic\single\GoodsSingle;
use think\Request;

class MusicCollectionServer extends ServerBase
{

    /**
     * @var array|mixed
     */
    private $param;

    function __construct(Request $request)
    {
        $this->request=$request;
        $this->param=$request->param();
        $this->model = new MusicCollectionApiModel();
    }
    function getList(){
        [$page,$limit] = $this->getPage($this->param);
        $this->param['type'] = $this->param['type']??10;
        $this->param['user_id'] = $this->request->user_id;
        [$list,$count] = $this->model->getApiList($this->param,'*',$page,$limit);
        $result['data']=$list;
        $result['count']=$count;
        $this->getMessageCode('adminMessage.success.select',2);
        return $result;
    }
    function collection(){
        $goods_id = $this->param['goods_id']??0;
        $type = $this->param['type']??0;
        if(empty($goods_id) || empty($type)){
            $this->getMessageCode('code_common.illegal',1);
            return false;
        }
        $res = $this->model->collection_op($this->request->user_id,$goods_id,$type);
    }
}